/*
 * @Author: Wyvonj 
 * @Date: 2018-04-19 16:47:44 
 * @Last Modified by: Wyvonj
 * @Last Modified time: 2018-04-20 14:48:03
 */
import Vue from 'vue'
import VueRouter from 'vue-router'
import Vuex from 'vuex'
import Cookie from 'js-cookie'
import Vuetify from 'vuetify'

import {
  router
} from './router'
import store from './store'

import 'vuetify/dist/vuetify.min.css'
import './style/custom.less'
import _ from 'lodash'

import Root from './pages/Root.vue'

window.Cookie = Cookie
window._ = _

Vue.use(Vuex)
Vue.use(VueRouter)
Vue.use(Vuetify, {
  theme: {
    primary: '#009688',
    secondary: '#b0bec5',
    accent: '#4db6ac',
    error: '#b71c1c',
    light: '#f1f1f1'
  }
})

// 权限指令
Vue.directive('has', {
  bind: function (el, binding) {
    if (!Vue.prototype.$_has(binding.value)) {
      Vue.nextTick(() => {
        el.parentNode.removeChild(el)
      })
    }
  }
})

// 代理等级
Vue.filter('ProxyLevel', function (value) {
  const strVal = value + ''
  switch (strVal) {
    case '0':
      return '普通玩家'
    case '1':
      return '总代理'
    case '2':
      return '一级代理'
    case '3':
      return '二级代理'
    default:
      return '暂未定义'
  }
})

// 业务员等级
Vue.filter('SalesLevel', function (value) {
  const strVal = value + '';
  switch (strVal) {
    case '1':
      return '见习业务员';
    case '2':
      return '正式业务员';
    case '3':
      return '高级业务员';
    case '4':
      return '见习经理';
    case '5':
      return '正式经理';
    case '6':
      return '高级经理';
    case '7':
      return '见习总监';
    case '8':
      return '正式总监';
    case '9':
      return '高级总监';
    default:
      return '未定义';
  }
})

document.addEventListener('DOMContentLoaded', () => {
  const $Vue = new Vue({
    router,
    store, // 注入到所有子组件
    components: {
      Root
    }
  })
  router.onReady(() => {
    $Vue.$mount('#root')
  })
  window.$Vue = $Vue
})